package com.dha.caodangcongnghe;

import com.dha.status.NetworkStatus;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.Toast;

public class ChonNgay extends Activity {

	private Button btOk;
	private DatePicker datePicker;
	private NetworkStatus networkStatus;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.layout_diablog_chonngay);
		btOk = (Button) findViewById(R.id.bt_ChonNgay);
		datePicker = (DatePicker) findViewById(R.id.datepicket_chonngay);
		networkStatus = new NetworkStatus(getBaseContext());
		btOk.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				if (networkStatus.isConnected()) {
					String thang = (datePicker.getMonth() + 1) + "";
					if (thang.length() == 1) {
						thang = "0" + thang;
					}
					String ngay = datePicker.getDayOfMonth() +"";
					if (ngay.length() == 1) {
						ngay = "0" + ngay;
					}
					
					String ngayDang = datePicker.getYear() + "-" + thang + "-"
							+ ngay;
					
					
					finish();
					
//					Intent itentThongBaoTheoNgay = new Intent("XemThongBaoTheoNgay");
//					itentThongBaoTheoNgay.putExtra("Ngay", ngayDang);
//					startActivity(itentThongBaoTheoNgay);
					
					Intent intent = new Intent("ThongBao");
					intent.putExtra("NgayDang", ngayDang);
					startActivity(intent);
					
				} else {
					Intent intentLoi = new Intent("SuCoVeKetNoiMang");
					startActivity(intentLoi);
				}

			}
		});
	}
}
